/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.ultrasoft.farmasoft.domain;

import java.io.Serializable;
import java.util.Collection;
import java.util.Date;

import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author Administrador
 */
@Entity
@Table(name = "package")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Package.findAll", query = "SELECT p FROM Package p"),
    @NamedQuery(name = "Package.findByPackageId", query = "SELECT p FROM Package p WHERE p.packageId = :packageId"),
    @NamedQuery(name = "Package.findByBatchNumber", query = "SELECT p FROM Package p WHERE p.batchNumber = :batchNumber"),
    @NamedQuery(name = "Package.findByPackage1", query = "SELECT p FROM Package p WHERE p.package1 = :package1"),
    @NamedQuery(name = "Package.findByDateIncome", query = "SELECT p FROM Package p WHERE p.dateIncome = :dateIncome"),
    @NamedQuery(name = "Package.findByDueDate", query = "SELECT p FROM Package p WHERE p.dueDate = :dueDate"),
    @NamedQuery(name = "Package.findByUnitsPerPack", query = "SELECT p FROM Package p WHERE p.unitsPerPack = :unitsPerPack"),
    @NamedQuery(name = "Package.findByCost", query = "SELECT p FROM Package p WHERE p.cost = :cost"),
    @NamedQuery(name = "Package.findByUnitCost", query = "SELECT p FROM Package p WHERE p.unitCost = :unitCost"),
    @NamedQuery(name = "Package.findByRemark", query = "SELECT p FROM Package p WHERE p.remark = :remark"),	
    @NamedQuery(name = "Package.findByProviderIdByUserProviderIdByActive", query = "SELECT p FROM Package p WHERE p.userprovider.userproviderPK.providerId = :providerId AND p.userprovider.userproviderPK.userProviderId = :userProviderId AND p.active = :active"),
    @NamedQuery(name = "Package.findByProviderIdByProductIdByPharmacyIdByActive", query = "SELECT p FROM Package p WHERE p.pharmacyproduct.pharmacyproductPK.providerId = :providerId AND p.pharmacyproduct.pharmacyproductPK.productId = :productId AND p.pharmacyproduct.pharmacyproductPK.pharmacyId = :pharmacyId AND p.active = :active"),
    @NamedQuery(name = "Package.findByProviderIdByProductIdByPharmacyIdByActiveByState", query = "SELECT p FROM Package p WHERE p.pharmacyproduct.pharmacyproductPK.providerId = :providerId AND p.pharmacyproduct.pharmacyproductPK.productId = :productId AND p.pharmacyproduct.pharmacyproductPK.pharmacyId = :pharmacyId AND p.active = :active AND p.state = :state"),
    @NamedQuery(name = "Package.findByActive", query = "SELECT p FROM Package p WHERE p.active = :active")})
public class Package implements Serializable {
    private static final long serialVersionUID = 1L;
    /*
    @Id
    @Basic(optional = false)
    @Column(name = "packageId")*/
    @Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
    private Integer packageId;
    @Column(name = "state")
    private short state;    
	@Column(name = "batchNumber")
    private Integer batchNumber;
    @Basic(optional = false)
    @Column(name = "package")
    private boolean package1;
    @Basic(optional = false)
    @Column(name = "dateIncome")
    @Temporal(TemporalType.DATE)
    private Date dateIncome;
    @Basic(optional = false)
    @Column(name = "dueDate")
    @Temporal(TemporalType.DATE)
    private Date dueDate;
    @Column(name = "unitsPerPack")
    private Short unitsPerPack;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "cost")
    private Double cost;
    @Column(name = "unitCost")
    private Double unitCost;
    @Column(name = "remark")
    private String remark;   
    
	@Column(name = "uniquePrice1")
    private Boolean uniquePrice1;
	@Column(name = "tempUniquePrice1")
    private Boolean tempUniquePrice1;
    @Column(name = "amountFixe1")
    private Double amountFixe1;
    @Column(name = "percentage1")
    private Double percentage1;       
    @Column(name = "tempTotal1")
    private Double tempTotal1;    
    @Column(name = "uniquePrice2")
    private Boolean uniquePrice2;
    @Column(name = "tempUniquePrice2")
    private Boolean tempUniquePrice2;
	@Column(name = "amountFixe2")
    private Double amountFixe2;
    @Column(name = "percentage2")
    private Double percentage2;
    @Column(name = "tempTotal2")
    private Double tempTotal2;    
    
    @Column(name = "active")
    private Boolean active;
    @OneToMany(mappedBy = "packageId")
    private Collection<Transaction> transactionCollection;
    @JoinColumns({
        @JoinColumn(name = "Pha_providerId", referencedColumnName = "providerId"),
        @JoinColumn(name = "pharmacyId", referencedColumnName = "pharmacyId"),
        @JoinColumn(name = "productId", referencedColumnName = "productId")})
    @ManyToOne
    private Pharmacyproduct pharmacyproduct;
    @JoinColumns({
        @JoinColumn(name = "providerId", referencedColumnName = "providerId"),
        @JoinColumn(name = "userProviderId", referencedColumnName = "userProviderId")})
    @ManyToOne
    private Userprovider userprovider;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "package1")
    private Collection<Item> itemCollection;

    public Package() {
    }

    public Package(Integer packageId) {
        this.packageId = packageId;
    }

    public Package(Integer packageId, boolean package1, Date dateIncome, Date dueDate) {
        this.packageId = packageId;
        this.package1 = package1;
        this.dateIncome = dateIncome;
        this.dueDate = dueDate;
    }

    public Integer getPackageId() {
        return packageId;
    }

    public void setPackageId(Integer packageId) {
        this.packageId = packageId;
    }

    public short getState() {
		return state;
	}

	public void setState(short state) {
		this.state = state;
	}
	
    public Integer getBatchNumber() {
        return batchNumber;
    }

    public void setBatchNumber(Integer batchNumber) {
        this.batchNumber = batchNumber;
    }

    public boolean getPackage1() {
        return package1;
    }

    public void setPackage1(boolean package1) {
        this.package1 = package1;
    }

    public Date getDateIncome() {
        return dateIncome;
    }

    public void setDateIncome(Date dateIncome) {
        this.dateIncome = dateIncome;
    }

    public Date getDueDate() {
        return dueDate;
    }

    public void setDueDate(Date dueDate) {
        this.dueDate = dueDate;
    }

    public Short getUnitsPerPack() {
        return unitsPerPack;
    }

    public void setUnitsPerPack(Short unitsPerPack) {
        this.unitsPerPack = unitsPerPack;
    }

    public Double getCost() {
        return cost;
    }

    public void setCost(Double cost) {
        this.cost = cost;
    }

    public Double getUnitCost() {
        return unitCost;
    }

    public void setUnitCost(Double unitCost) {
        this.unitCost = unitCost;
    }

    public String getRemark() {
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public Boolean getUniquePrice1() {
		return uniquePrice1;
	}

	public void setUniquePrice1(Boolean uniquePrice1) {
		this.uniquePrice1 = uniquePrice1;
	}

	public Boolean getTempUniquePrice1() {
		return tempUniquePrice1;
	}

	public void setTempUniquePrice1(Boolean tempUniquePrice1) {
		this.tempUniquePrice1 = tempUniquePrice1;
	}
	
	public Double getAmountFixe1() {
		return amountFixe1;
	}

	public void setAmountFixe1(Double amountFixe1) {
		this.amountFixe1 = amountFixe1;
	}

	public Double getPercentage1() {
		return percentage1;
	}

	public void setPercentage1(Double percentage1) {
		this.percentage1 = percentage1;
	}

	public Double getTempTotal1() {
		return tempTotal1;
	}

	public void setTempTotal1(Double tempTotal1) {
		this.tempTotal1 = tempTotal1;
	}
	
	public Boolean getUniquePrice2() {
		return uniquePrice2;
	}

	public void setUniquePrice2(Boolean uniquePrice2) {
		this.uniquePrice2 = uniquePrice2;
	}

	public Boolean getTempUniquePrice2() {
		return tempUniquePrice2;
	}

	public void setTempUniquePrice2(Boolean tempUniquePrice2) {
		this.tempUniquePrice2 = tempUniquePrice2;
	}
	
	public Double getAmountFixe2() {
		return amountFixe2;
	}

	public void setAmountFixe2(Double amountFixe2) {
		this.amountFixe2 = amountFixe2;
	}

	public Double getPercentage2() {
		return percentage2;
	}

	public void setPercentage2(Double percentage2) {
		this.percentage2 = percentage2;
	}
	
	public Double getTempTotal2() {
		return tempTotal2;
	}

	public void setTempTotal2(Double tempTotal2) {
		this.tempTotal2 = tempTotal2;
	}
    
    public Boolean getActive() {
        return active;
    }

    public void setActive(Boolean active) {
        this.active = active;
    }

    @XmlTransient
    public Collection<Transaction> getTransactionCollection() {
        return transactionCollection;
    }

    public void setTransactionCollection(Collection<Transaction> transactionCollection) {
        this.transactionCollection = transactionCollection;
    }

    public Pharmacyproduct getPharmacyproduct() {
        return pharmacyproduct;
    }

    public void setPharmacyproduct(Pharmacyproduct pharmacyproduct) {
        this.pharmacyproduct = pharmacyproduct;
    }

    public Userprovider getUserprovider() {
        return userprovider;
    }

    public void setUserprovider(Userprovider userprovider) {
        this.userprovider = userprovider;
    }

    @XmlTransient
    public Collection<Item> getItemCollection() {
        return itemCollection;
    }

    public void setItemCollection(Collection<Item> itemCollection) {
        this.itemCollection = itemCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (packageId != null ? packageId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Package)) {
            return false;
        }
        Package other = (Package) object;
        if ((this.packageId == null && other.packageId != null) || (this.packageId != null && !this.packageId.equals(other.packageId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.ultrasoft.farmasoft.domain.Package[ packageId=" + packageId + " ]";
    }
    
}
